import { ref } from "vue";

export default (item) => {
  let ruleForm = ref({
    passWord: "",
    userName: "",
    code:"",
    uuid:""
  });

  let ruleFormRef = ref();

  const rules = ref({
    userName: [
      { required: true, message: "请输入账号密码", trigger: "blur" },
      { min: 3, max: 5, message: "Length should be 3 to 5", trigger: "blur" },
    ],
    passWord: [
      {
        required: true,
        message: "Please input Activity name",
        trigger: "blur",
      },
      { min: 3, max: 5, message: "Length should be 3 to 5", trigger: "blur" },
    ],
  });

  const submite = async (form) => {
   if (!form) return
   await form.validate((valid, fields) => {
     if (valid) {
       console.log('submit!')
     } else {
       console.log('error submit!', fields)
     }
   })
 }

  return {
    ruleForm,
    submite,
    ruleFormRef,
    rules,
  };
};
